package com.hospital.vac.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.vac.entity.Notification;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

public interface NotificationMapper extends BaseMapper<Notification> {
    @Insert("INSERT INTO notifications(user_id,title,message,banner,link,created_at) VALUES(#{userId},#{title}, #{message},#{banner}, #{link},#{createdAt})")
    void insertNotification(Notification notification);

    @Select("SELECT * FROM notifications WHERE user_id=#{userId} ORDER BY created_at DESC")
    List<Notification> getNotificationsByUserId(Long userId);

    @Update("UPDATE notifications SET read_at=#{readAt} WHERE id=#{id}")
    void markNotificationAsRead(Long id, LocalDateTime readAt);
}